<?php
/**
 * Created Page.php.
 * User: 1971229701@qq.com
 * Date: 2020/7/7
 * Time: 16:38
 * Name: Administrator
 */

namespace app\common\helper;


use app\common\logic\LogicBase;

trait Page
{
    /**
     * 分页类
     * @param string $key
     * @param string $default
     * @return mixed
     */
    public function param($key = '', $default = '')
    {

        $val = input('get' . $key, null);
        if (is_null($val)) {

            $val = input('post' . $key, $default);

        }

        return $val;
    }

    public function getPagingParams()
    {

        $pageIndex = $this->param('page', 1);
        $pageSize = $this->param('page_size', 10);
        return ($pageIndex - 1) * $pageSize . ',' . $pageSize;
    }
}
